package tech.xs.workflow.bpmn;

import org.dom4j.Element;
import tech.xs.workflow.bpmn.constant.BpmnElementConstant;
import tech.xs.workflow.bpmn.element.SequenceFlowElement;

import java.util.ArrayList;
import java.util.List;

public class BpmnSequenceFlowElementHelper {

    public static List<SequenceFlowElement> analyze(Element process) {
        List<SequenceFlowElement> sequenceFlowList = new ArrayList<>();
        List<Element> elements = process.elements(BpmnElementConstant.SEQUENCE_FLOW);
        for (Element element : elements) {
            SequenceFlowElement bpmnSequenceFlow = new SequenceFlowElement();
            bpmnSequenceFlow.setId(element.attributeValue("id"));
            bpmnSequenceFlow.setSourceRef(element.attributeValue("sourceRef"));
            bpmnSequenceFlow.setTargetRef(element.attributeValue("targetRef"));
            sequenceFlowList.add(bpmnSequenceFlow);
        }
        return sequenceFlowList;
    }

}
